package com.guigu.www.luolujin.Service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.guigu.www.luolujin.Service.LljDiseaseService;
import com.guigu.www.mapper.DiseaseMapper;
import com.guigu.www.pojo.Disease;
import com.guigu.www.pojo.PageVo;
import com.guigu.www.pojo.TemplateFood;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 作者 罗露金
 */
@Service
public class LljDiseaseServiceImpl implements LljDiseaseService {
    @Autowired
    DiseaseMapper mapper;

    @Override
    public PageVo<Disease> pageDisease(Integer pageNum, Integer pageSize, String disName) {
        QueryWrapper<Disease> wrapper = new QueryWrapper<>();
        wrapper.like("dis_name",disName);
        Page page = new Page(pageNum, pageSize);
        IPage iPage = mapper.selectPage(page, wrapper);
        PageVo<Disease> PageVo = new PageVo<>();
        PageVo.setRows(iPage.getRecords());
        PageVo.setTotal(iPage.getTotal());
        return PageVo;
    }

    @Override
    public void insertDisease(Disease disease) {
        mapper.insert(disease);
    }

    @Override
    public void updateDisease(Disease disease) {
        mapper.updateById(disease);
    }

    @Override
    public void deleteDisease(int disId) {
        mapper.deleteById(disId);
    }

    @Override
    public Disease selectById(int disId) {
        return mapper.selectById(disId);
    }
}
